package com.sk.cardeal.adapter;

import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sk.cardeal.R;
import com.sk.cardeal.entity.Project;
import com.sk.cardeal.utils.MyUtils;

import java.util.List;

/**
 * Created by sk on 2018/2/3.
 */

public class FormProjectAdapter extends BaseQuickAdapter<Project, BaseViewHolder> {

    public FormProjectAdapter(int layoutResId, @Nullable List<Project> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, Project item) {

        helper.setText(R.id.project_name, item.getProjectName())
                .setText(R.id.work_money, "工费：" + MyUtils.mul(item.getManHours(), item.getManHoursPrice()))
                .setText(R.id.price, String.valueOf(item.getEditPrice()))
                .setText(R.id.edit_money, String.valueOf(item.getEditPrice()))
                .addOnClickListener(R.id.edit_btn)
                .addOnClickListener(R.id.finish_edit)
                .addOnClickListener(R.id.right);

        if (item.isOpen()) {
            helper.setGone(R.id.edit_ll, true);
            helper.setGone(R.id.normal_ll, false);
        } else {
            helper.setGone(R.id.edit_ll, false);
            helper.setGone(R.id.normal_ll, true);
        }
    }
}
